package com.rentplant;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rentplant.Pojo.order;
import com.rentplant.service.impl.orderServiceImp;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Rollback(value = false)
@RunWith(SpringRunner.class)
public class rentItem  extends ApplicationTest{
//    订单服务
    @Autowired
    private orderServiceImp orderserviceimp;

    @Test
    public void test(){
        order orderinfo = new order("oasdasd","2023-03-03 22:01:15","2023-03-03 22:01:15","2023-03-03 22:01:15","2023-03-03","2023-07-12","",
                                    "2023-04-03 22:01:15",40,300,"物品自提","测试姓名","4451215156","九江学院","待发货",
                                    "[\"http://127.0.0.1:8080/image/download?name=92d9e6c0-4545-4536-86fd-8d002c01d80e.jpg\"]","线下交货",
                                    "xidnjgndfi-asdnjkcnxv","i1677669528985");

        JSONObject order = (JSONObject) JSON.toJSON(orderinfo);
        //修改订单的属性名
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("orderID","orderid"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("orderGenTime","ordergentime"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("orderPayTime","orderpaytime"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("rentStartTime","rentstarttime"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("rentEndTime","rentendtime"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("rentDays","rentdays"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("rentPayment","rentpayment"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("deliveryMethod","deliverymethod"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("receiveName","receivename"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("receivePhone","receivephone"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("deliveryAddress","deliveryaddress"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("orderRemark","orderremark"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("UserIdForOrder","userid"));
        order = (JSONObject) JSON.parse(JSON.toJSONString(order).replace("ItemIdForOrder","itemid"));
        System.out.println(order);
        boolean result = orderserviceimp.payOrder(order);
        System.out.println(result);

    }

}
